package day06;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class DC {

	    public static void main(String[] args) {
	        List<Student> list = new ArrayList<Student>();
	        add(list);
	        ergodicPrint(list);
	        changeMaxAgeName(list);
	        System.out.println("-------------");
	        ergodicPrint(list);

	    }

	    private static void changeMaxAgeName(List<Student> list) {
	        Optional<Student> op = list.stream()
	                .sorted((s1, s2) -> (s2.getAge()-s1.getAge()))
	                .findFirst();
	        Student student = op.get();
	        student.setName("ahahah");
	    }

	    private static void ergodicPrint(List<Student> list) {
	        for(int i = 0;i<list.size();i++){
	            System.out.println(list.get(i));
	        }
	    }

	    private static void add(List<Student> list) {
	        list.add(new Student("QA",20,"女","99"));
	        list.add(new Student("QW",20,"男","98"));
	        list.add(new Student("QE",20,"女","100"));
	    }
	    

	
}
